package ru.study.thinkin.chapter11;

import java.util.Iterator;

public class IterableClass implements Iterable<String>{
	protected String[] words = "And that is how".split(" ");
	
	public Iterator<String> iterator() {
		
		return new Iterator<String>() {
			int index =0 ;

			@Override
			public boolean hasNext() {				
				return index < words.length;
			}

			@Override
			public String next() {				
				return words[index++];
			}

			@Override
			public void remove() {
				throw new UnsupportedOperationException();
			}
		};
	}
	
	public static void main(String[] args) {
		for(String s : new IterableClass()) {
			System.out.print(s+" ");
		}

	}

}
